define(function (require) {
    var _common = require('common/main');
    var _config = require('common/config');
    var _send = _common.sendRequest;
    function init() {
    	$('#new_bus_confirm').click(_save_zone_bus);
    	
    	var _param = {};
    	_send("listRegion.ajax",_param,_bus_region_render);
    }
    
    function _bus_region_render(data)
    {
    	var _html = '';
    	var _len = data.length;
    	for (var i = 0; i < _len; i++) 
    	{
    		var _item = data[i];
    		_html += '<option value="';
    		_html += _item.id;
			_html += '">';
    		_html += _item.name;
    		_html += '</option>';
    	}
    	$('#bus_region').html(_html);
    }
    
    function _save_zone_bus()
    {
    	//get from session or cookie
    	var _userid = 0;
    	var _zonename = $('#bus_zonename').val();
    	var _region = $('#bus_region option:selected').attr("value");
    	var _param = _common.stringify({
			userid : _userid,
			zonename : _zonename,
			region : _region,
		});
    	_send("saveZonebus.ajax",_param,_save_bus_render);
    }
    
    function _save_bus_render(data)
    {
    	if(data)
		{
    		alert("新增成功");
    		window.close();
		}
    	else
		{
    		alert("新增失败，请修改后重新提交");
		}
    }
    
    return { init: init };
});